﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using BaseCardTypes = Wormhole.Engine.CardLibrary.BaseCardTypes;

namespace Wormhole.UI.Application.Controls.Cards
{
	/// <author>Rodney McKay</author>
	/// <date>06 April 2008</date>
	/// <summary>
	/// Render a card in the player's hand.
	/// </summary>
	public class HandCard : Card
	{
		#region Constructor
		/// <summary>
		/// Initialize a default instance of the class.
		/// </summary>
		public HandCard() : base()
		{
		}

		/// <summary>
		/// Create a new instance of the control to render the specific card.
		/// </summary>
		/// <param name="card">The engine card that should be rendered.</param>
		public HandCard(BaseCardTypes.Card card) : base(card)
		{
		}
		#endregion

		#region Set Size
		/// <summary>
		/// Set the card size.
		/// </summary>
		protected override void SetSize()
		{
			// small card: 91.7, 84.7, 60% orignal 131, 121
			this.cardImage.Width = 131 * 0.85;
			this.cardImage.Height = 121 * 0.85;
			this.cardImage.Stretch = Stretch.Fill;

			this.outsideBorder.Width = this.cardImage.Width + 10;
			this.outsideBorder.Height = this.cardImage.Height + 10;

			this.Width = this.outsideBorder.Width;
			this.Height = this.outsideBorder.Height;
		}
		#endregion

		#region Event Handlers

		#region Double Click
		/// <summary>
		/// Override the double click event.
		/// </summary>
		protected override void OnDoubleClick()
		{
			base.OnDoubleClick();
		}
		#endregion

		#endregion

		#region Play Card
		/// <summary>
		/// Play a card form the hand.
		/// </summary>
		public void PlayCard()
		{
			this.EngineCard.Play();
		}
		#endregion

		#region Display Status
		/// <summary>
		/// Display the card status with the appropriate border.
		/// </summary>
		public override void DisplayStatus()
		{
			base.DisplayStatus();


			if (this.EngineCard.InputStatus == BaseCardTypes.InputStatus.AllowPlay)
			{
				if (this.EngineCard.CanPlay())
					this.glowEffect.Opacity = 1;
				else
					this.glowEffect.Opacity = 0;
			}
		}
		#endregion

	}
}
